#include "gtest/gtest.h"

#include "components/post.h"
#include "mimetypes.h"

class TestPost : public ::testing::Test
{
protected:
	void SetUp()
	{
		new Wishmaster::MimeTypes();
	}

	void TearDown()
	{
		delete Wishmaster::MimeTypes::instance();
	}
};

TEST_F(TestPost,Properties)
{
	Wishmaster::PostPtr post = Wishmaster::PostPtr(new Wishmaster::Post(Wishmaster::PostId("chan", "/b/", 15, 10)));

	post->addReply(Wishmaster::PostId("chan", "/b/", 15, 12));
	post->addReply(Wishmaster::PostId("chan", "/b/", 15, 23));
	ASSERT_TRUE(post->replies().contains(Wishmaster::PostId("chan", "/b/", 15, 12)));
	ASSERT_TRUE(post->replies().contains(Wishmaster::PostId("chan", "/b/", 15, 23)));
	ASSERT_EQ(2, post->replies().size());

	post->clearReplies();
	ASSERT_EQ(0, post->replies().size());
}

TEST_F(TestPost,Attachments)
{
	Wishmaster::PostPtr post = Wishmaster::PostPtr(new Wishmaster::Post(Wishmaster::PostId("chan", "/b/", 15, 10)));
	Wishmaster::AttachmentPtr attach0 = Wishmaster::Attachment::create(QUrl("http://www.nonexistant.com/picture_thumb.jpg"), QUrl("http://www.nonexistant.com/picture.jpg"));
	Wishmaster::AttachmentPtr attach1 = Wishmaster::Attachment::create(QUrl("http://www.nonexistant.com/picture_thumb2.jpg"), QUrl("http://www.nonexistant.com/picture2.jpg"));
	post->addAttachment(attach0);
	post->addAttachment(attach1);
	ASSERT_EQ(2, post->attachmentCount());
}

